package com.shenmazong.serveredustudent.controller;

import com.shenmazong.serveredustudent.pojo.*;
import com.shenmazong.serveredustudent.service.*;
import com.shenmazong.utils.ResultResponse;
import com.shenmazong.vo.ListParamVo;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author 满天星斗
 * @version 1.0
 * @description: 学管中心
 * @date 2021/9/18 14:42
 */

@RestController
@RequestMapping("/stu")
@Api(tags = "学生管理接口")
public class StudentController {

    @Autowired
    private TbStudentService studentService;

    @Autowired
    private TbCollageService collageService;

    @Autowired
    private TbMajorService majorService;

    @Autowired
    private TbStageService stageService;

    @Autowired
    private TbClazzService clazzService;

    @Autowired
    private TbExamGradeService examGradeService;


    /**
     * @return com.shenmazong.utils.ResultResponse
     * @description getStudentPage
     * @params [listParamVo]
     * @author S1763
     * @date 2021/9/18 17:24
     */
    //获取学生列表分页
    //参数当期页，每页条数，学院Id,专业Id，阶段Id,课程Id (long类型)
    @PostMapping("/getStudentPage")
    public ResultResponse getStudentPage(@RequestBody ListParamVo listParamVo) {
        return studentService.getStudentPage(listParamVo);
    }

    /**
     * @description getStudentListByCollageId
            * @params [listParamVo]
            * @return com.shenmazong.utils.ResultResponse
            * @author S1763
            * @date 2021/9/23 16:12
            */
    //学院下所有的学生
    @PostMapping("/getStudentListByCollageId")
    public ResultResponse getStudentListByCollageId(@RequestBody ListParamVo listParamVo) {
        return studentService.getStudentListByCollageId(listParamVo);
    }

    /**
     * @return com.shenmazong.utils.ResultResponse
     * @description saveStudentToSchool
     * @params [student]
     * @author S1763
     * @date 2021/9/19 8:40
     */
    //学生入学
    @PostMapping("/saveStudentToSchool")
    public ResultResponse saveStudentToSchool(@RequestBody TbStudent student, @RequestBody TbCollage collage, @RequestBody TbMajor major,@RequestBody TbClazz clazz) {
        return studentService.saveStudentToSchool(student.getStuId(), collage.getCollageId(), major.getMajorId(),clazz.getClazzId());
    }

    /**
     * @return com.shenmazong.utils.ResultResponse
     * @description StudentTransfor
     * @params [user_id, clazz_id]
     * @author S1763
     * @date 2021/9/19 11:05
     */
    //学生转学
    @PostMapping("/StudentTransfor")
    public ResultResponse StudentTransfor(Long stuId,Long oldClazzId,Long newClazzId) {
        return studentService.StudentTransfor(stuId, oldClazzId,newClazzId);
    }

    /**
     * @return com.shenmazong.utils.ResultResponse
     * @description getAllCollage
     * @params []
     * @author S1763
     * @date 2021/9/19 11:06
     */
    //查询所有学院
    @PostMapping("/getAllCollage")
    public ResultResponse getAllCollage() {
        return collageService.getAllCollage();
    }

    /**
     * @return com.shenmazong.utils.ResultResponse
     * @description getCollageByCollageId
     * @params [collageId]
     * @author S1763
     * @date 2021/9/19 11:11
     */
    //根据collageId查询学院
    @PostMapping("/getCollageByCollageId")
    public ResultResponse getCollageByCollageId(@RequestBody TbCollage collage) {
        return collageService.getCollageByCollageId(collage.getCollageId());
    }

    /**
     * @return com.shenmazong.utils.ResultResponse
     * @description getMajorByCollageId
     * @params [collageId]
     * @author S1763
     * @date 2021/9/19 11:12
     */
    //根据学院Id查询以下的专业
    @PostMapping("/getMajorByCollageId")
    public ResultResponse getMajorByCollageId(@RequestBody TbCollage collage) {
        return majorService.getMajorByCollageId(collage.getCollageId());
    }

    /**
     * @return com.shenmazong.utils.ResultResponse
     * @description getStageByMajorId
     * @params [majorId]
     * @author S1763
     * @date 2021/9/21 19:33
     */
    //根据专业Id查询以下的阶段
    @PostMapping("/getStageByMajorId")
    public ResultResponse getStageByMajorId(@RequestBody TbMajor major) {
        return stageService.getStageByMajorId(major.getMajorId());
    }


    /**
     * @return com.shenmazong.utils.ResultResponse
     * @description getClazzsByStageId
     * @params [stageId]
     * @author S1763
     * @date 2021/9/21 19:46
     */
    //查询阶段下所有的班级
    @PostMapping("/getClazzsByStageId")
    public ResultResponse getClazzsByStageId(@RequestBody TbStage stageId) {
        return clazzService.getClazzsByStageId(stageId.getStageId());
    }

    /**
     * @return com.shenmazong.utils.ResultResponse
     * @description updateStudentInfo
     * @params [student]
     * @author S1763
     * @date 2021/9/21 20:06
     */
    //修改学生信息
    @PostMapping("/updateStudentInfo")
    public ResultResponse updateStudentInfo(@RequestBody TbStudent student) {
        return studentService.updateStudentInfo(student);
    }

    /**
     * @description deleteStudentInfo
            * @params [stuId]
            * @return com.shenmazong.utils.ResultResponse
            * @author S1763
            * @date 2021/9/22 9:18
            */
    //删除学生信息
    @PostMapping("/deleteStudentInfo")
    public ResultResponse deleteStudentInfo(@RequestBody TbStudent student) {
        return  studentService.deleteStudentInfo(student.getStuId());
    }


    /**
     * @description updateStudentStatus
            * @params [stuId, status]
            * @return com.shenmazong.utils.ResultResponse
            * @author S1763
            * @date 2021/9/22 9:17
            */
    //学会状态：正常在校，2：休学，3：毕业，4：请假，0：退学
    @PostMapping("/updateStudentStatus")
    public ResultResponse updateStudentStatus(@RequestBody TbStudent student){
        Byte stuStatus = student.getStuStatus();
        Integer integer = Integer.valueOf(stuStatus);
        return studentService.updateStudentStatus(student.getStuId(),integer);
    }

    /**
     * @description changeClazzByGrade
            * @params [student]
            * @return com.shenmazong.utils.ResultResponse
            * @author S1763
            * @date 2021/9/23 10:15
            */
    //学生升班末班
    @PostMapping("/changeClazzByGrade")
    public ResultResponse changeClazzByGrade(@RequestBody TbStudent student,@RequestBody TbClazz clazz){
        return studentService.changeClazzByGrade(student.getStuId(),clazz.getClazzId());
    }



    /**
     * @description getStudentGradeByCollageId
            * @params [listParamVo]
            * @return com.shenmazong.utils.ResultResponse
            * @author S1763
            * @date 2021/9/22 20:27
            */
    //学生成绩列表(参数为：当前页，总页数，【学院Id,专业Id,阶段Id,班级Id】其四之一)
    @PostMapping("/getStudentGradePage")
    public ResultResponse getStudentGradePage(@RequestBody ListParamVo listParamVo){
        return examGradeService.getStudentGradePage(listParamVo);
    }


    @PostMapping("/getStudentGrade")
    public ResultResponse getStudentGrade(@RequestBody ListParamVo listParamVo){
        return examGradeService.getStudentGrade(listParamVo);
    }








}
